/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ages.devtools

import com.ages.entity.Model
import com.ages.env.AbstractWorld
import com.ages.input.SKeyboard
import com.ages.test.HelloWorldWorld
import java.awt.Component
import java.awt.List
import java.awt.Panel
import javax.swing.JSlider
import scala.collection.mutable.ArrayBuffer
import java.awt.List
import com.ages.entity.Joint

object SkeletonModeler {

  /**
   * @param args the command line arguments
   */

  val width = 800
  val height = 600

  val version = "v0.0.1"
  def main(args: Array[String]): Unit = {
    val world:AbstractWorld = new HelloWorldWorld

    val keys = new SKeyboard()


//    var skeleton = new Joint("pelvis")
//    val rl = new Joint("RLeg")
//    val ll = new Joint("LLeg")
//    rl.addJoint(new Joint("RFoot"))
//    ll.addJoint(new Joint("LFoot"))
//    skeleton.addJoint(rl)
//    skeleton.addJoint(ll)
//    skeleton.addKeys(keys)
//
//    println(skeleton.map("pelvis"))
//
//    println(skeleton.flatList)
//    println(skeleton.getChildrenDeep)
//    println(skeleton.children)

    val m = new Model("/com/ages/test/res/skeleton_test.xml")
    val skeleton = m.base
    m.base.addKeys(keys)
    world.addEntity(skeleton)

    skeleton.printXMLTags

    println(skeleton.getChildrenDeep)
    println(skeleton.children)
    
    
    val lst = new List()
    lst.addActionListener(skeleton)
    lst.setSize(100, height)
    val slider = new JSlider()
    slider.setMaximum(100)
    slider.setMinimum(0)
    slider.setMajorTickSpacing(10)
    slider.setPaintTicks(true)
    slider.setMinorTickSpacing(5)
    slider.setPaintLabels(true)
//    slider.setSize(width-100, 100)
    slider.setBounds(0,0, width, 100)
//    slider
    for(js <- skeleton.flatList)
      lst.add(js.toString)

    val components = new ArrayBuffer[(Component,String)]()
    val leftPanel = new Panel
    val bottomPanel = new Panel
    bottomPanel.add(slider)
    leftPanel.add(lst)
    components += ((leftPanel,"West"))
    components += ((bottomPanel,"South"))



    val gameWindow = new ModelWindow("Skeleton Modeler "+version,world,width,height,components)
    gameWindow.addKeylistener(keys)
   
  }
}
